#ifndef THREADTASKS_H
#define THREADTASKS_H

#include <QThread>
#include "../tcp/basetcp.h"
#include <QMutex>
#include <QMutexLocker>
#include <QWaitCondition>

#include <mutex>
#include <condition_variable>
#include "util/realdatamodel.h"


class BaseTcp;
class BaseUdp;

class ThreadTasks : public QThread
{
    Q_OBJECT
public:
    explicit ThreadTasks(QObject *parent = nullptr);

    void setTcp(BaseTcp* tp)
    {
        tcp = tp;
    }

signals:
    void emitHandle(QByteArray ba);
    void notifyMainWindowSignal(RealDataModel RealDataModel);

public slots:
    void onReceiveFromTcp(QByteArray ba);

    ///控制器连接状态控制
    void onHandle(QByteArray ba);

protected:
    void run();

private:
    QMutex mutex;
    QByteArray rawData;
//    QSharedPointer<BaseTcp> tcp;
    BaseTcp* tcp;
    QAtomicInt isNotify;

    RealDataModel realDataModel;
    int nRet = 0;

    QString parseCommand(const QByteArray& rawData);
};

#endif // THREADTASKS_H
